<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php $show_header = false; ?>
<?php include $this->admin_tpl('header', 'admin');?>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script>
<script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script>
<script type="text/javascript">
<!--
$(function(){
	$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});

	$("#username").formValidator({
		onshow:"<?php echo L('input').L('username')?>",
		onfocus:"<?php echo L('username').L('between_2_to_20')?>"}).inputValidator({
			min:2,max:20,onerror:"<?php echo L('username').L('between_2_to_20')?>"}).regexValidator({
				regexp:"ps_username",
				datatype:"enum",
				onerror:"<?php echo L('username').L('format_incorrect')?>"}).ajaxValidator({
	    type : "post",
		url : "<?php echo U('Member/Member/verify_username') ?>",
		data :{'username':this.value},
		datatype : "json",
		async:'false',
		success : function(data){
            if( data == "1" ) {
                return true;
			} else {
                return false;
			}
		},
		buttons: $("#dosubmit"),
		onerror : "<?php echo L('deny_register').L('or').L('user_already_exist')?>",
		onwait : "<?php echo L('connecting_please_wait')?>"
	});

	$("#password").formValidator({onshow:"<?php echo L('input').L('password')?>",onfocus:"<?php echo L('password').L('between_6_to_20')?>"}).inputValidator({min:6,max:20,onerror:"<?php echo L('password').L('between_6_to_20')?>"});

	$("#pwdconfirm").formValidator({
		onshow:"<?php echo L('input').L('cofirmpwd')?>",
		onfocus:"<?php echo L('passwords_not_match')?>",
		oncorrect:"<?php echo L('input_correct')?>"}).compareValidator({
			desid:"password",
			operateor:"=",
			onerror:"<?php echo L('passwords_not')?>"
		});

	//$("#point").formValidator({
		//tipid:"pointtip",
		//onshow:"<?php echo L('input').L('point')?>",
		//onfocus:"<?php echo L('point').L('between_1_to_8_num')?>"}).regexValidator({
			//regexp:"^\\d{1,8}$",
			//onerror:"<?php echo L('point').L('between_1_to_8_num')?>"
		//});
	$("#email").formValidator({
		onshow:"<?php echo L('input').L('email')?>",
		onfocus:"<?php echo L('email').L('format_incorrect')?>",
		oncorrect:"<?php echo L('email').L('format_right')?>"}).inputValidator({
			min:2,max:32,onerror:"<?php echo L('email').L('between_2_to_32')?>"}).regexValidator({
				regexp:"email",
				datatype:"enum",
				onerror:"<?php echo L('email').L('format_incorrect')?>"}).ajaxValidator({
				    type : "post",
					url : "<?php echo U('Member/Member/verify_email') ?>",
					data :{'email':this.value},
					datatype : "json",
					async:'false',
					success : function(data){	
			            if( data == "1" ) {
			                return true;
						} else {
			                return false;
						}
					},
					buttons: $("#dosubmit"),
					onerror : "<?php echo L('deny_register').L('or').L('email_already_exist')?>",
					onwait : "<?php echo L('connecting_please_wait')?>"
	});
	$("#nickname").formValidator({
		onshow:"<?php echo L('input').L('nickname')?>",
		onfocus:"<?php echo L('nickname').L('between_2_to_20')?>"}).inputValidator({
			min:2,max:20,onerror:"<?php echo L('nickname').L('between_2_to_20')?>"}).regexValidator({
				regexp:"ps_username",
				datatype:"enum",
				onerror:"<?php echo L('nickname').L('format_incorrect')?>"}).ajaxValidator({
				    type : "post",
					url : "<?php echo U('Member/Member/verify_nickname') ?>",
					data :{'nickname':this.value},
					datatype : "json",
					async:'false',
					success : function(data){
			            if( data == "1" ) {
			                return true;
						} else {
			                return false;
						}
					},
					buttons: $("#dosubmit"),
					onerror : "<?php echo L('already_exist')?>",
					onwait : "<?php echo L('connecting_please_wait')?>"
		}).defaultPassed();
	// $('#mobile').mouseover(function(){		
	// 	$('#mobile_msg').html("<?php echo L('mobile') ?>");
	// });
	$('#mobile').focus(function(){
		$('#mobile_msg').html("<?php echo L('mobile') ?>");
	});
	$('#mobile').blur(function(){
		if(this.value){
			if(/^\d+$/.test(this.value) && this.value.length == 11){
				$.ajax({
					type:"post",
					url:"<?php echo U('Member/Member/verify_mobile') ?>",
					datatype:"json",
					data:{'mobile':this.value},
					async:'false',
					success:function(data){
						if( data == "1" ) {
							$('#mobile_msg').html("<?php echo L('input_correct') ?>");
			                return true;
						} else {
							$('#mobile_msg').html("<?php echo L('mobile_error') ?>");
			                return false;
						}
					}

				});
			}else{
				$('#mobile_msg').html("<?php echo L('mobile') ?>");
				return false;
			}
		}else{
			$('#mobile_msg').html("<?php echo L('choose') ?>");
		}
	});
	// $('#mobile').mouseleave(function(){
	// 	if(this.value){			
	// 		if(/^\d+$/.test(this.value)){
	// 			alert(this.value);
	// 		}else{
	// 			$('#mobile_msg').html("<?php echo L('mobile') ?>");
	// 		}
	// 	}else{
	// 		$('#mobile_msg').html("<?php echo L('choose') ?>");
	// 	}	
	// });
});
//-->
</script>
<div class="pad-10">
<div class="common-form">
<form name="myform" action="<?php echo U('add');?>" method="post" id="myform">
<fieldset>
	<legend><?php echo L('basic_configuration')?></legend>
	<table width="100%" class="table_form">
		<tr>
			<td width="80"><?php echo L('username')?></td> 
			<td><input type="text" name="info[username]"  class="input-text" id="username"></input></td>
		</tr>
		<tr>
			<td><?php echo L('password')?></td> 
			<td><input type="password" name="info[password]" class="input-text" id="password" value=""></input></td>
		</tr>
		<tr>
			<td><?php echo L('cofirmpwd')?></td> 
			<td><input type="password" class="input-text" id="pwdconfirm" value=""></input></td>
		</tr>
		<tr>
			<td><?php echo L('nickname')?></td> 
			<td><input type="text" name="info[nickname]" id="nickname" value="" class="input-text"></input></td>
		</tr>
		<tr>
			<td><?php echo L('email')?></td>
			<td>
			<input type="text" name="info[email]" value="" class="input-text" id="email" size="30"></input>
			</td>
		</tr>
		<tr>
			<td><?php echo L('mp')?></td>
			<td>
				<input type="text" name="info[mobile]" value="" class="input-text" id="mobile" size="15"></input>
				<div id="mobile_msg" class="onShow"><?php echo L('choose') ?></div>
			</td>
		</tr>
		<tr>
			<td><?php echo L('member_group')?></td>
			<td>
			<?php echo $form::select($grouplist, '1', 'name="info[modelid]"', '');?>
			</td>
		</tr>
		<!-- <tr>
			<td><?php //echo L('point')?></td> -->
			<!-- <td>
			<input type="text" name="info[point]" value="" class="input-text" id="point" size="10"></input>
			</td>
		</tr> -->
	</table>
</fieldset>

    <div class="bk15"></div>
    <input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog">
</form>
</div>
</div>
</body>
</html>